package org.springblade.modules.restaurant.job;

import cn.hutool.core.date.DateUtil;
import com.aizuda.snailjob.client.job.core.annotation.JobExecutor;
import com.aizuda.snailjob.client.job.core.dto.JobArgs;
import com.aizuda.snailjob.client.model.ExecuteResult;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.modules.restaurant.service.IBusinessObjectivesService;
import org.springframework.stereotype.Component;

/**
 * 营业目标生成任务
 * @author harry
 * @公众号 Harry技术
 */
@Slf4j
@Component
@AllArgsConstructor
@JobExecutor(name = "businessObjectivesJobExecutor")
public class BusinessObjectivesJobExecutor {
	private final IBusinessObjectivesService businessObjectivesService;

	public ExecuteResult jobExecute(JobArgs jobArgs) {
		log.info("生成营业目标===>jobArgs:{}", jobArgs);

		String time = DateUtil.formatDate(DateUtil.date());
		businessObjectivesService.updateBusinessObjectives(time);

		return ExecuteResult.success();
	}


//	@PostConstruct
	public void init() {
		log.info("生成营业目标任务启动");
		String time = DateUtil.formatDate(DateUtil.date());
		businessObjectivesService.updateBusinessObjectives(time);
	}
}
